const { log } = require("../src/utils/console-logger")

const arr = [0xF7, 0x7F, 0x01, 0x01, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x01, 0xAA]
const content = [0x49, 0x59, 0x4B, 0x5F, 0x39, 0x39, 0x39, 0x39, 0x39 ,0x39, 0x39, 0x39]
const all = arr.concat(content)
console.log('all', all)

console.log('calCrc', calCrc(all))

const sum = all.reduce((a,b) => a+b ) + 1
console.log('sum & 0xff', sum, sum & 0xff)
const sunB = sum.toString(2)
console.log('sunB', sunB)
const r = sunB.substring(sunB.length - 8)
console.log(parseInt(r, 2).toString(16))
all.push(parseInt(r, 2))
console.log(all)

function calCrc(bufArray) {
    return bufArray.reduce((a,b) => a+b ) + 1 & 0xff
}

const a = 1036
console.log(a & 0xff) // 低八位
console.log((a & 0xff00) >> 8); // 高八位

console.log(parseInt('40c', 16));